
#ifndef _TIME_H_20111201
#define _TIME_H_20111201

#include <time.h>
#include <string>
#include "Core.h"

namespace AirlineRes
{

/// Stores a time of day and date in the UTC time zone, and provides methods to
/// retrieve the stored data either numerically or as a formatted string.
class TimeDate
{
public:
  TimeDate(){};
  ~TimeDate(){};

  /// Construct TimeDate object by calling appropriate SetTime method to initialise the stored time.
  TimeDate( int _year,
            int _month,
            int _day,
            int _hour   = 0,
            int _minute = 0  );

  /// Construct TimeDate object by calling appropriate SetTime method to initialise the stored time.
  TimeDate( std::string const& ddmmyyyy );

  /// Construct TimeDate object by calling appropriate SetTime method to initialise the stored time.
  TimeDate( std::string const& _ddmmyyyy, std::string const& _hhmm );

  /// Sets the time represented by this object equal to that of the time specified by the supplied arguments.
  void SetTime( int _year,
                int _month,
                int _day,
                int _hour   = 0,
                int _minute = 0  );

  /// Sets the time represented by this object equal to that of the date in the supplied string.
  ///
  /// @param _ddmmyyyy  String containing date in ddmmyyyy format.
  void TimeDate::SetTime( std::string const& _ddmmyyyy );

  /// Sets the time represented by this object equal to that of the time and date in the supplied strings.
  ///
  /// @param _ddmmyyyy  String containing date in ddmmyyyy format.
  /// @param _hhmm      String containing time in hhmm format.
  void TimeDate::SetTime( std::string const& _ddmmyyyy, std::string const& _hhmm );

  /// Sets this TimeDate object to the current system time.
  void TimeDate::SetToCurrentTime();

  /// Get a pointer to a tm struct based on the internal time_t representation of the stored time.
  ///
  /// @return Pointer to tm struct.
  tm* GetTm() const;

  /// @return  The minute 0-59.
  inline int GetMinute() const;
  /// @return  The hour 0-23.
  inline int GetHour() const;

  /// @return  The day of the month 1-31.
  inline int GetDay() const;
  /// @return  The month 1-12.
  inline int GetMonth() const;
  /// @return  The year.
  inline int GetYear() const;

  /// @return  String representing stored date in yyyymmdd format.
  std::string GetISODate() const;
  /// @return  String representing stored date in ddmmyyyy format.
  std::string GetDDMMYYYY() const;
  /// @return  String representing stored time in hhmm format.
  std::string GetHHMM() const;

private:
  time_t m_time;
};

} // namespace AirlineRes

#endif // _TIME_H_20111201